package com.qf.listener;

import com.qf.pojo.MsgObj;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/*
    consumeMode = ConsumeMode.ORDERLY,消费模式设置为顺序消费后，在消费队列消息时，内部会加锁，保证消息的消费顺序
            当消费者消费消息时出现问题，一致阻塞等待问题解决 -- 保障消息的绝对顺序
 */
@Component
@RocketMQMessageListener(topic = "test2",consumerGroup = "test2-consumer-group1",consumeMode = ConsumeMode.ORDERLY)
public class Consumer3 implements RocketMQListener<MsgObj> {
    @Override
    public void onMessage(MsgObj message) {
        System.out.println("Consumer3:消息数据:" + message);
    }
}
